<template>
  <div class="search-input">
    <el-input class="input" :style="{width: width}" :size="size" :value="value" v-bind="$attrs" @input="changeValue" :clearable="clearable" @clear="clear" @keypress.native.enter="search()"></el-input>
    <el-button :size="size" @click="search()" type="primary">{{ $t('packet.搜索') }}</el-button>
  </div>
</template>

<script>
export default {
  name: "index",
  inheritAttrs: false,
  props: {
    value: {
      type: String,
      default() {
        return '';
      },
    },
    size: {
      type: String,
      default() {
        return 'medium';
      },
    },
    width: {
      type: String,
      default() {
        return '200px';
      },
    },
    clearable: {
      type: Boolean,
      default() {
        return true;
      },
    }
  },
  methods: {
    changeValue(value) {
      this.$emit('update:value', value);
    },
    clear() {
      this.changeValue('');
      this.search();
    },
    search() {
      this.$emit('search')
    },
  }
}
</script>

<style scoped lang="less">
.search-input{
  display: flex;
  .input{

  }
}
</style>
